package dk.dashboardFP.panels.displayPanel {
	import flash.display.DisplayObject;
	import flash.events.Event;

	import dk.dashboardFP.panels.displayPanel.core.EditorItem;
	import dk.dashboardFP.panels.displayPanel.marks.AbstractObjectMark;

	import flash.display.Sprite;

	/**
	 * @author josef
	 */
	public class SelectionMark extends AbstractObjectMark {

		protected var _oEI : EditorItem;

		public function SelectionMark(oEI : EditorItem, sprContainer : Sprite) {
			_oEI = oEI;
			super(oEI.doTarget, sprContainer);
		}

		override protected function setupElements() : void {
			super.setupElements();
			
			_oEI.registerSelection(this);
			
			//:::::::
			// edit mark 
			_doAsset.alpha = 0.5;
			
			//:::::::
			// updater 
			addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true);
			addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage, false, 0, true);
		}

		
		override protected function updateMark() : void {
			super.updateMark();
			
			// delta mark
			if (_oEI.doTarget.x != _oEI.originalPosX || _oEI.doTarget.y != _oEI.originalPosY ) {
				_doLabel.sText += "   ( " + (_oEI.doTarget.x - _oEI.originalPosX) + " , " + (_oEI.doTarget.y - _oEI.originalPosY) + " )";
				_doLabelBack.width = _doLabel.width + 4; 
			}
		}

		private function onRemovedFromStage(event : Event) : void {
			removeEventListener(Event.ENTER_FRAME, onEnterFrame);
		}

		private function onEnterFrame(event : Event) : void {
			if (_rectBounds.toString() != _doTarget.getBounds(_sprContainer).toString()) {
				updateMark();
			}
		}
		
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// show messurements
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

		public function showMessurements(pointTarget : DisplayObject) : void {
			
		}
	}
}
